<?php
namespace app\common\models;


class Product extends BaseModel
{

    protected $auto = [];
    protected $insert = ['status' => 1, 'create_time'];
    protected $update = [];

    protected function setCreateByAttr(){
        return $this->getAdminCreateBy();
    }


    public function getLists($where,$pageSize=20){
        return $this->where($where)->with('category')->order('create_time DESC')->paginate($pageSize);
    }

    public function category(){
        return $this->hasOne(ProductCategory::class,'id','category_id',[],'left')->field('id,title');
    }
}